﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace HengTong.DataAccess.Migrations
{
    /// <inheritdoc />
    public partial class 添加调休和加班关联表 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropColumn(
                name: "OvertimeRequestBillIds",
                table: "SysDailyCompOffRequestBill");

            migrationBuilder.AddColumn<Guid>(
                name: "BillId",
                table: "SysAttendanceRecord",
                type: "uniqueidentifier",
                nullable: true);

            migrationBuilder.CreateTable(
                name: "SysCompOffOvertimeLink",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    CompOffRequestBillId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    OvertimeRequestBillId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    HoursUsed = table.Column<decimal>(type: "decimal(8,2)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SysCompOffOvertimeLink", x => x.ID);
                    table.ForeignKey(
                        name: "FK_SysCompOffOvertimeLink_SysDailyCompOffRequestBill_CompOffRequestBillId",
                        column: x => x.CompOffRequestBillId,
                        principalTable: "SysDailyCompOffRequestBill",
                        principalColumn: "ID",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_SysCompOffOvertimeLink_SysDailyOvertimeRequestBill_OvertimeRequestBillId",
                        column: x => x.OvertimeRequestBillId,
                        principalTable: "SysDailyOvertimeRequestBill",
                        principalColumn: "ID");
                });

            migrationBuilder.CreateIndex(
                name: "IX_SysCompOffOvertimeLink_CompOffRequestBillId",
                table: "SysCompOffOvertimeLink",
                column: "CompOffRequestBillId");

            migrationBuilder.CreateIndex(
                name: "IX_SysCompOffOvertimeLink_OvertimeRequestBillId",
                table: "SysCompOffOvertimeLink",
                column: "OvertimeRequestBillId");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "SysCompOffOvertimeLink");

            migrationBuilder.DropColumn(
                name: "BillId",
                table: "SysAttendanceRecord");

            migrationBuilder.AddColumn<string>(
                name: "OvertimeRequestBillIds",
                table: "SysDailyCompOffRequestBill",
                type: "nvarchar(2000)",
                maxLength: 2000,
                nullable: true);
        }
    }
}
